#include<bits/stdc++.h>
using namespace std;
int GetCount(vector<int>& num)
{
    int n = num.size();
    vector<int> dp(n + 1, 10000);
    dp[0] = 1;
    for (int current_pos = 1; current_pos <= n; current_pos++)
    {
        for (int pre_pos = current_pos - 1; pre_pos >= 0; pre_pos--)
        {
            if (num[pre_pos] == 0)
                continue;
            if (pre_pos + num[pre_pos] >= current_pos)
                dp[current_pos] = min(dp[current_pos], dp[pre_pos] + 1);
        }
    }
    if (dp[n] == 10000)
        return -1;
    else
        return dp[n] - 1;
}

int main()
{
    int N = 0;
//    cin >> N;
    vector<int> num = {2,0,1,1,1};
//    for (int i = 0; i < N; i++)
//        cin >> num[i];
    cout << GetCount(num) << endl;
    return 0;
}